/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pku.lbs.web.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import pku.lbs.web.UploadWeb;

/**
 *
 * @author yongchao
 */
public class UploadServlet extends BaseServlet {

    private enum ActionEnum {
        UPLOAD_FILE,
        SEND_MESSAGE,
        SEND_SINGLE_MESSAGE,
        UPLOAD_SINGLE_FILE
    }

    @Override
    protected String processAction(String action, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String jsonStr = null;
        UploadWeb webBean = UploadWeb.getInstance();
        switch (ActionEnum.valueOf(action)) {
            case UPLOAD_FILE:
                jsonStr = webBean.doUploadFile(request, response);
                break;
            case SEND_MESSAGE:
                jsonStr = webBean.doSendMsg(request, response);
                break;
            case SEND_SINGLE_MESSAGE:
                jsonStr = webBean.doSendSingleMsg(request, response);
                break;
            case UPLOAD_SINGLE_FILE:
                jsonStr = webBean.doSendSingleMsg(request, response);
                break;
        }
        return jsonStr;
    }
}
